package alp.starcode.nudtportal.user.controller;

import alp.starcode.common.result.Result;
import alp.starcode.nudtportal.framework.aspect.model.CheckSign;
import alp.starcode.nudtportal.framework.model.dto.RequestExceptionDTO;
import alp.starcode.nudtportal.framework.model.dto.UserLoginLogIDTO;
import alp.starcode.nudtportal.user.service.UserAccountService;
import alp.starcode.nudtportal.framework.aspect.model.UserActionLog;
import alp.starcode.nudtportal.framework.model.dto.UserBehaviorDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户相关接口控制类
 *
 * @author hyc
 * @date 2022-05-26
 */
@RestController
@Api(tags = "用户相关接口")
@RequestMapping("/user")
@Slf4j
public class UserAccountController {
    @Autowired
    UserAccountService userAccountService;


    @PostMapping("recordUserBehavior.gif")
    @ApiOperation("记录用户行为日志")
//    @UserActionLog(accessType = "0", businessName = "记录用户行为")
    @CheckSign
    public Result<Boolean> recordUserBehavior(@RequestBody UserBehaviorDTO userBehaviorDTO) {
        return Result.success(userAccountService.recordUserBehavior(userBehaviorDTO));
    }

    @PostMapping("recordUserLoginLog.gif")
    @ApiOperation("记录用户登录失败日志")
    @CheckSign
    public Result<Boolean> recordUserLoginInfo(@RequestBody UserLoginLogIDTO userLoginLogIDTO) {
        return Result.success(userAccountService.recordUserLoginInfo(userLoginLogIDTO));
    }

    @PostMapping("recordUserRequestException.gif")
    @ApiOperation("记录用户请求异常日志")
    @CheckSign
    public Result<Boolean> recordUserRequestException(@RequestBody RequestExceptionDTO requestExceptionDTO) {
        return Result.success(userAccountService.recordUserRequestException(requestExceptionDTO));
    }
}
